﻿#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 ZHENG Zhong <heavyzheng nospam-at gmail D0T com>
# - http://heavyz.blogspot.com/
# - http://buggarden.blogspot.com/
#
# Created on 2008-12-10.
# $Id: models.py 305 2008-12-19 12:51:21Z heavyzheng $
#

from google.appengine.ext import db

MODELS_REVISION = "$Revision: 305 $"

class Dummy(db.Model):

    timestamp = db.DateTimeProperty(required=True)
    ip_addr   = db.StringProperty()
    accessed  = db.IntegerProperty(default=1)
    order     = db.StringProperty()
    
    def put(self):
        self.order = self.timestamp.strftime("%Y%m%d_%H%M%S")
        return super(Dummy, self).put()
    
    @staticmethod
    def get_next(limit, next=None):
        if next:
            query = Dummy.gql("WHERE order>:next ORDER BY order", next=next)
        else:
            query = Dummy.gql("ORDER BY order")
        return query.fetch(limit)


